package com.dubbo.consomer.freamwork;

import java.io.Serializable;

/**
 * 
 * Restful接口统一输出格式
 *
 */
public class RestfulResult implements Serializable {
    
    private static final long serialVersionUID = 827560194166970585L;
    
    private int code;
    
    private String msg;
    
    private Object data;
    
    public static RestfulResult fail() {
        return new RestfulResult(500, "操作失败");
    }

    public static RestfulResult fail(String message) {
        return new RestfulResult(500, message);
    }

    public static RestfulResult fail(int code, String message) {
        return new RestfulResult(code, message);
    }
    
    public static RestfulResult succeed() {
        return new RestfulResult(200, "OK");
    }
    
    public static RestfulResult succeed(Object body) {
        return new RestfulResult(200, "OK", body);
    }

    public RestfulResult() {
    }

    public RestfulResult(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public RestfulResult(int code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
}
